package edu.aut.bme.hu.orkomet.dal;

import com.hp.hpl.jena.db.DBConnection;
import com.hp.hpl.jena.db.IDBConnection;

// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
import java.sql.DriverManager;
// #[regen=yes,id=DCE.E552ECE9-BA38-B048-3EC7-A076BC9652C8]
import java.sql.SQLException;
// </editor-fold> 
public class DerbyDAL {

    {
        String className = "org.apache.derby.jdbc.EmbeddedDriver";
        try {
            Class.forName(className).newInstance();                                   // Load the Driver
        } catch (Exception ex) {
            ex.printStackTrace();
        }                                   // Load the Driver
    }
    
    static IDBConnection conn = null;

    public static IDBConnection getConnection() {
        if (conn == null) {
            //conn = new DBConnection("jdbc:derby://localhost:1527/Orkomet", "ork", "ork", "Derby");
            conn = new DBConnection("jdbc:derby:Orkomet;create=true", "ork", "ork", "Derby");
        }
        return conn;
    }
    
    public static void shutDownDerby() throws SQLException{
    	if(conn!=null)
    		DriverManager.getConnection("jdbc:derby:;shutdown=true");
    }
}

